#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)
/**
 * Definition for a Node.
 * struct Node {
 *     int val;
 *     struct Node *next;
 *     struct Node *random;
 * };
 */

//struct Node* copyRandomList(struct Node* head) {
//    struct Node* cur = head;
//    while (cur)
//    {
//        struct Node* copy = (struct Node*)malloc(sizeof(struct Node));
//        struct Node* copy = cur->next;
//        copy->val = cur->val;
//        copy->next = cur->next;
//        cur->next = copy;
//        cur = cur->next->next;
//    }
//    cur = head;
//    while (cur)
//    {
//        struct Node* copy = cur->next;
//        if (cur->random == NULL)
//        {
//            copy->random = NULL;
//        }
//        else
//        {
//            copy->random = cur->random->next;
//        }
//        cur = cur->next->next;
//    }
//    cur = head;
//    struct Node* newhead = NULL, * tail = NULL;
//    while (cur)
//    {
//        struct Node* next = cur->next->next;
//        struct Node* coy = cur->next;
//        if (tail == NULL)
//        {
//            newhead = tail = copy;
//        }
//        else
//        {
//            tail->next = cur->next;
//            tail = tail->next;
//        }
//        cur->next = next
//            cur = cur->next;
//    }
//    return newhead;
//}